/**
 * @author lk
 * @date 2022/6/6 19:31
 */
package com.mmall.thread;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

public class ThreadPoolTest01 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(100);
        List<Future<LocalDateTime>> res = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            PrintThread2 printThread2 = new PrintThread2();
            res.add(executorService.submit(printThread2));
        }
        res.forEach(e-> {
            try {
                System.out.println(e.get());
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            } catch (ExecutionException ex) {
                ex.printStackTrace();
            }
        });
    }
}

class PrintThread2 implements Callable<LocalDateTime> {
    @Override
    public LocalDateTime call() throws Exception {
        for (int i = 0; i < 4; i++) {
            System.out.println(i);
        }
        return LocalDateTime.now();
    }
}
